﻿using Serilog;
using Worldme.YHChatSDK.Framework.EventInterface;
using Worldme.YHChatSDK.Framework.Vo;

namespace YHChatSDKDemo.Plugins
{
    /// <summary>
    /// 用户退出群事件插件示例
    /// </summary>
    public class GroupLeaveDemo : EventGroupLeave
    {
        /// <summary>
        /// 相同事件插件中的优先级，越小越优先
        /// </summary>
        public int Order => 0;

        /// <summary>
        /// 返回-1，后面的实现类将不再执行
        /// 返回0，后面的实现类继续执行
        /// </summary>
        /// <param name="eventMsgVo"></param>
        /// <returns></returns>
        public int Handle(EventMsgVo eventMsgVo)
        {
            String chatId = eventMsgVo.@event.chat.chatId;
            String userId = eventMsgVo.@event.sender.senderId;
            String nickname = eventMsgVo.@event.sender.senderNickname;
            Log.Information("【用户退出群事件】群号[{chatId}]：用户[{userId}]（{nickname}）退出本群", chatId, userId, nickname);
            //返回-1则不再投递后面的同事件插件
            //返回0则继续投递给后面的同事件插件处理
            return 0;
        }
    }
}
